﻿<%@ Page Language="C#" AutoEventWireup="True" CodeBehind="TypeManagement.aspx.cs" Inherits="Medianamik.UI.TypeManagement.TypeManagement" MasterPageFile="../MasterPages/MedianamikModule.Master" %>
<%@ Register Src="Controls/MultipleTemplatePicker.ascx" TagPrefix="ctrl" TagName="MultipleTemplatePicker" %>
<%@ Register src="Controls/IconPicker.ascx" tagname="IconPicker" tagprefix="uc1" %>

<asp:Content ID="HeaderContentHolder" runat="server" ContentPlaceHolderID="HeaderContentHolder"></asp:Content>

<asp:Content ID="ContextMenuContent" ContentPlaceHolderID="ContextMenu" runat="server">
    <asp:LinkButton ID="btnSave" runat="server" CssClass="Action BtSauvegarder" OnClick="btnSave_Click" Text='<%$ Resources: medianamik_global, Action_SaveTooltip %>' />
    <a href="<%= ReturnURL %>" class="Action BtAnnuler"><%=Resources("medianamik_global", "Action_CancelTooltip") %></a>
</asp:Content>

<asp:Content ID="CenterContent" ContentPlaceHolderID="CenterContent" runat="server">

    <telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="btnSave" EventName="OnClick">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="uplForm" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManagerProxy>

	<asp:UpdatePanel ID="uplValidation" runat="server" UpdateMode="Always">
		<ContentTemplate> 
	        <asp:ValidationSummary ID="valSummary" EnableClientScript="false" runat="server" CssClass="ValidationSummary" />
        </ContentTemplate>
    </asp:UpdatePanel><br />

    <telerik:RadTabStrip id="RadTabStrip1" MultiPageID="RadMultiPage1"
       runat="server" Skin="Medianamik" EnableEmbeddedSkins="false" CausesValidation="false" ShowBaseLine="True">
       <Tabs>
           <telerik:RadTab Text='<%$ Resources: medianamik_tabs, type %>' PageViewID="Type" Selected="true" />
           <telerik:RadTab Text='<%$ Resources: medianamik_tabs, generation %>' PageViewID="Generation" />
           <telerik:RadTab Text='<%$ Resources: medianamik_tabs, hierarchy %>' PageViewID="HierarchyRules" />
           <telerik:RadTab Text='<%$ Resources: medianamik_tabs, interface %>' PageViewID="Interfaces" />
       </Tabs>
    </telerik:RadTabStrip>

    <telerik:RadMultiPage id="RadMultiPage1" SelectedIndex="0" Runat="server" CssClass="TabPage">
       <telerik:RadPageView id="Type" runat="server" CssClass="ContainerEditeurPage">
            <asp:UpdatePanel ID="TypeUpdatePanel" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">
                <ContentTemplate>
                    <label class="EditionPage"><%=Resources("medianamik_typemanagement","TypeName") %><span class="ChampObligatoire">*</span>
                    <asp:RequiredFieldValidator ID="reqTypeName"  runat="server" ControlToValidate="txtTypeName" ErrorMessage="<%$ Resources: medianamik_typemanagement, TypeNameRequired %>" Display="None" />
                    <asp:CustomValidator ID="TypeNameValidator" runat="server" ControlToValidate="txtTypeName" ErrorMessage="<%$ Resources : Medianamik_TypeManagement, TypeNameIsInvalid %>" OnServerValidate="TypeNameValidator_ServerValidate" Display="None"  />
                    <asp:CustomValidator ID="TypeNameUnicityValidator" runat="server" ErrorMessage="<%$ Resources: Medianamik_TypeManagement, TypeNameAlreadyExists %>" OnServerValidate="TypeNameUnicityValidator_ServerValidate" Display="None" />
                    </label>
                    <p><asp:TextBox ID="txtTypeName" runat="server" CssClass="TxtBox" /></p><br />
                    <p><med:TranslatorBox runat="server"  ID="TypeNameTranslations" Required="true" ErrorMessage='<%$ Resources: medianamik_typemanagement, TranslationRequired %>'  /></p><br />
                    <label class="EditionPage"><%=Resources("medianamik_typemanagement","Icon") %></label><p><uc1:IconPicker ID="IconPicker" runat="server" /></p><br />
                    <label class="EditionPage"><%=Resources("medianamik_typemanagement","Description") %></label><p><asp:TextBox CssClass="TxtBox" runat="server" id="txtTypeDescription" TextMode="MultiLine" ></asp:TextBox></p><br />
                    <p><asp:CheckBox ID="chkCanHaveChilds" runat="server" Text='<%$ Resources: medianamik_typemanagement,Inheritable %>' /></p><br />
                    <p><asp:CheckBox ID="chkIsAbstract" runat="server" Text='<%$ Resources: medianamik_typemanagement,IsAbstract %>' /></p><br />
                    <p><asp:CheckBox ID="chkIsSystem" runat="server" Text='<%$ Resources: medianamik_typemanagement,IsSystem %>' /></p><br />
                    <p><asp:CheckBox ID="chkIndexable" Checked="true" runat="server" Text='<%$ Resources: medianamik_typemanagement,IsIndexable %>' /></p><br />
                    <p><asp:CheckBox ID="chkListable" onclick="toggleVersionCheckBox(this.checked)" runat="server" Text='<%$ Resources: medianamik_typemanagement,IsListable %>' />
                       <span style="color:Red;font-weight:bold;">!! Si cochée, le type deviendra non versionnable !!</span> 
                    </p><br />
                    <p><asp:CheckBox ID="chkIsVersioned" Checked="true" runat="server" Text="<%$ Resources: medianamik_typemanagement, IsVersionedCheckboxLabel %>" />
                     <span style="color:Red;font-weight:bold;">!! Si décochée, les données publiées seront effacées !!</span> 
                     </p>
                    <asp:PlaceHolder ID="phrTemplates" runat="server" Visible="false">
                        <p><ctrl:MultipleTemplatePicker ID="templatePicker" runat="server" /></p><br />
                    </asp:PlaceHolder>
                </ContentTemplate>
            </asp:UpdatePanel>
       </telerik:RadPageView>
       <telerik:RadPageView id="Generation" runat="server" CssClass="ContainerEditeurPage">
        <asp:UpdatePanel runat="server">
            <ContentTemplate>
                <p class="Check">
                    <asp:CheckBox ID="chkMayBeGenerated" runat="server" onclick="toggleGenerationCheckBox(this.checked)" Text='<%$ Resources: medianamik_typemanagement,IsGenerated %>' />
                </p>
                <p class="Check">
                    <asp:CheckBox runat="server" ID="cbCreate" Text='<%$ Resources: medianamik_typemanagement, Create %>' /><br />
                    <asp:CheckBox runat="server" ID="cbRead" Text='<%$ Resources: medianamik_typemanagement, Read %>' /><br />
                    <asp:CheckBox runat="server" ID="cbUpdate" Text='<%$ Resources: medianamik_typemanagement, Update %>' /><br />
                    <asp:CheckBox runat="server" ID="cbDelete" Text='<%$ Resources: medianamik_typemanagement, Delete %>' /><br />
                </p>
                <p class="Check">
                    <asp:CheckBox runat="server" ID="cbCSharp" Text='<%$ Resources: medianamik_typemanagement, CSharp %>' /><br />
                    <asp:CheckBox runat="server" ID="cbObjectiveC" Text='<%$ Resources: medianamik_typemanagement, ObjectiveC %>' /><br />
                    <asp:CheckBox runat="server" ID="cbCSharpWP7" Text='<%$ Resources: medianamik_typemanagement, CSharpWP7 %>'/><br />
                    <asp:CheckBox runat="server" ID="cbJavaAndroid" Text='<%$ Resources: medianamik_typemanagement, JavaAndroid %>'/><br />
                </p>
            </ContentTemplate>
        </asp:UpdatePanel>
       </telerik:RadPageView>
       <telerik:RadPageView id="HierarchyRules" runat="server" CssClass="ContainerEditeurPage">
            <asp:UpdatePanel ID="HierarchyUpdatePanel" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">
                <ContentTemplate>
                    <table cellpadding="0" cellspacing="0" border="0" Width="100%">
                        <tr>
                            <td width="50%" valign="top">
                                <h4><%=Resources("medianamik_typemanagement","LegalParents") %></h4>
                                <div class="BlocArbo">
                                    <telerik:RadTreeView runat="server" 
                                                         ID="legitimateParentTypeTree" 
                                                         Width="100%" 
                                                         Height="300" 
                                                         EnableEmbeddedSkins="false" 
                                                         Skin="Medianamik" 
                                                         OnNodeCheck="LegitimateParentTypeSelected" 
                                                         CheckBoxes="true" 
                                                         CausesValidation="false" />
                                    </div>
                            </td>
                            <td><img src="/medianamik/images/spacer.gif" width="16" height="1" /></td>
                            <td width="50%" valign="top">
                                <h4><%=Resources("medianamik_typemanagement","LegalParentNodes") %></h4>
                                <div class="BlocArbo">
                                    <telerik:RadTreeView runat="server" 
                                                         ID="legitimateParentNodeTree" 
                                                         Width="100%" 
                                                         Height="300" 
                                                         DataTextField="Name" 
                                                         DataValueField="ID" 
                                                         DataFieldID="ID" 
                                                         DataFieldParentID="ParentID" 
                                                         EnableEmbeddedSkins="false" 
                                                         Skin="Medianamik" 
                                                         CheckBoxes="true"
                                                         CausesValidation="false"
                                                         OnNodeExpand="LegitimateParentNodeTreeNodeExpanded" />
                                    </div>
                            </td>
                        </tr>
                    </table>
                </ContentTemplate>
            </asp:UpdatePanel>
       </telerik:RadPageView>
       <telerik:RadPageView id="Interfaces" runat="server" CssClass="ContainerEditeurPage">
            <asp:CustomValidator ID="InterfaceChoiceValidator" runat="server" Display="None" OnServerValidate="ValidateInterfaceChoice" />
            <med:InterfacePicker ID="InterfaceChoice" runat="server" OnClientValidate="openValidateInterfaceWindow" />
       </telerik:RadPageView>
    </telerik:RadMultiPage>
	
	<p><span class="ChampObligatoire">*</span><%=Resources("medianamik_global","RequiredField") %></p>
</asp:Content>

<asp:Content ID="ExternalContent" ContentPlaceHolderID="ExternalContentHolder" runat="server">
    <script type="text/javascript">
        //<![CDATA[
        function openValidateInterfaceWindow(interfaceId) {
            radopen('/medianamik/modalwindows/ValidateInterfaceWindow.aspx?interfaceid=' + interfaceId<%= CurrentType == null ? "" : " + '&typeid=" + CurrentType.ID + "'"%>, 'validateInterfaceWindow');
        }
        
        var previousStatus = <%= chkIsVersioned.Checked.ToString().ToLower() %>;
        function toggleVersionCheckBox(listChecked)
        {
            var verChk = document.getElementById('<%=chkIsVersioned.ClientID %>');
            var tmp = verChk.checked;
            if(listChecked)
            {
                verChk.checked = false;
                verChk.disabled = true;
            }
            else
            {
                verChk.checked = previousStatus;
                verChk.disabled = false;
            }
            previousStatus = tmp;
        }
        
        function toggleGenerationCheckBox(genChecked)
        {
            var cbCSharp = document.getElementById('<%=cbCSharp.ClientID %>');
            var cbObjectiveC = document.getElementById('<%=cbObjectiveC.ClientID %>');
            var cbCSharpWP7 = document.getElementById('<%=cbCSharpWP7.ClientID %>');
            var cbJavaAndroid = document.getElementById('<%=cbJavaAndroid.ClientID %>');
            var cbCreate = document.getElementById('<%=cbCreate.ClientID %>');
            var cbRead = document.getElementById('<%=cbRead.ClientID %>');
            var cbUpdate = document.getElementById('<%=cbUpdate.ClientID %>');
            var cbDelete = document.getElementById('<%=cbDelete.ClientID %>');
            
            if(genChecked)
            {
                cbCSharp.checked = false;
                cbCSharp.disabled = false;
                cbObjectiveC.checked = false;
                cbObjectiveC.disabled = false;
                cbCSharpWP7.checked = false;
                cbCSharpWP7.disabled = false;
                cbJavaAndroid.checked = false;
                cbJavaAndroid.disabled = false;
                cbCreate.checked = false;
                cbCreate.disabled = false;
                cbRead.checked = false;
                cbRead.disabled = false;
                cbUpdate.checked = false;
                cbUpdate.disabled = false;
                cbDelete.checked = false;
                cbDelete.disabled = false;
            }
            else
            {
               cbCSharp.checked = false;
                cbCSharp.disabled = true;
                cbObjectiveC.checked = false;
                cbObjectiveC.disabled = true;
                cbCSharpWP7.checked = false;
                cbCSharpWP7.disabled = true;
                cbJavaAndroid.checked = false;
                cbJavaAndroid.disabled = true;
                cbCreate.checked = false;
                cbCreate.disabled = true;
                cbRead.checked = false;
                cbRead.disabled = true;
                cbUpdate.checked = false;
                cbUpdate.disabled = true;
                cbDelete.checked = false;
                cbDelete.disabled = true;
            }
        }
        //]]>
    </script>
</asp:Content>
